package com.anmingle.exception;

import com.anmingle.enums.ErrorCode;

/**
 * @author 安明乐
 * @Title BusinessException
 * @Package IntelliJ IDEA
 * @date 2022/11/23 17:25
 */
public class BusinessException extends RuntimeException {

    private final int code;


    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(ErrorCode code, String message) {
        super(message);
        this.code = code.getCode();
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    public int getCode() {
        return code;
    }


}
